﻿using Kw.Combinatorics;
using System;

namespace Kw.CombinatoricsExamples
{
    class MulticombinationExample03
    {
        static void Main ()
        {
            // Create a k-multicombination of 6 choose 4:

            Multicombination mc = new Multicombination (6, 4);

            // Assign -1 to Rank to get the last rank:

            mc.Rank = -1;

            // A row can be treating as a string:

            string text = mc.ToString () + "  n=" + mc.Choices + ", k=" + mc.Picks + ", rank=" + mc.Rank;
            Console.WriteLine (text);

            // Increment/decrement operators will wrap-around if they go past limits:

            ++mc;
            Console.WriteLine ("\n{0}  n={1}, k={2}, rank={3}", mc, mc.Choices, mc.Picks, mc.Rank);

            // Create a k-multicombination of n=9 from the picks:

            mc = new Multicombination (9, new int[] { 1, 1, 3, 8 });

            Console.WriteLine ("\n{0}  n={1}, k={2}, rank={3}", mc, mc.Choices, mc.Picks, mc.Rank);
        }

        /* Output:

        { 5, 5, 5, 5 }  n=6, k=4, rank=125

        { 0, 0, 0, 0 }  n=6, k=4, rank=0

        { 1, 1, 3, 8 }  n=9, k=4, rank=185

        */
    }
}
